package com.zhuiYun.project.api.syslog.mapper;

import com.zhuiYun.project.api.syslog.entity.ImageFile;
import com.zhuiYun.project.api.syslog.entity.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @InterfaceName SysMapper
 * @Description TODO
 * @Author wuwan
 * @Date 2023/8/11 15:03
 **/
@Mapper
public interface SysMapper {
    /*
    * @Author wuwan
    * @Description  全查方法
    * @Date 2023/8/11 15:19
    * @Return
    * @param null
    */
    @Select("select su.*,sr.* from sys_user su,sys_role sr where su.role_id = sr.id;")
    List<SysUser> sysqueryall();
    /*
    * @Author wuwan
    * @Description 主表添加数据
    * @Date 2023/8/11 15:20
    * @Return
    * @param null
    */
    @Insert("insert into sys_user (user_name,user_login_name,user_password,user_sex,user_age,role_id,create_time,update_time,del_flag,img)" +
            "values (#{userName},#{userLoginName},#{userPassword},#{userSex},#{userAge},#{roleId},#{createTime},#{updateTime},#{delFlag},#{img})")
    Integer sysinsert( SysUser sysUser);
    /*
    * @Author wuwan
    * @Description 附表添加数据
    * @Date 2023/8/11 15:20
    * @Return
    * @param null
    */
    @Insert("insert into sys_role (role_name,role_remark,create_time,update_time)" +
            "values (#{roleName},#{roleRemark},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id") // 指定自增ID字段
    Integer sysinsertrole(SysUser sysUser);
    
    @Insert("insert into image_file (image_name,file_uuid_name,file_size,file_type,file_path,create_time)" +
            "values (#{imageName},#{fileUuidName},#{fileSize},#{fileType},#{filePath},#{createTime});")
    Integer insertimage(ImageFile file);
}
